package model;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityManager;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Query;
import javax.persistence.Transient;

import database.SingleEntityManagerFactory;

@Entity
public class SdkDynMapperXsd extends Model {
	
	private String fgType;
    SdkDynMapper cdDynMapper;
	SdkFile cdFile;
	
	public SdkDynMapperXsd() {
		cdDynMapper = new SdkDynMapper();
		cdFile = new SdkFile();
	}
	
	
	
	@Id
	@GeneratedValue
	@Override
	@Column (name="CDDYNMAPPERXSD")
	public int getId() {
		// TODO Auto-generated method stub
		return super.getId();
	}
	@Override
	public void setId(int id) {
		// TODO Auto-generated method stub
		super.setId(id);
	}



	public String getFgType() {
		return fgType;
	}



	public void setFgType(String fgType) {
		this.fgType = fgType;
	}


	@ManyToOne
	@JoinColumn (name="cdDynMapper")
	public SdkDynMapper getCdDynMapper() {
		return cdDynMapper;
	}



	public void setCdDynMapper(SdkDynMapper cdDynMapper) {
		this.cdDynMapper = cdDynMapper;
	}


	@ManyToOne
	@JoinColumn (name="cdFile")
	public SdkFile getCdFile() {
		return cdFile;
	}



	public void setCdFile(SdkFile cdFile) {
		this.cdFile = cdFile;
	}


	@Transient
	public List<SdkDynMapperXsd> getList(int code)
	{
		EntityManager session = SingleEntityManagerFactory.getInstance().createEntityManager();
		Query query = session.createQuery("FROM SdkDynMapperXsd where cddynmapper = :a"); 
		query.setParameter("a", code); 
		List<SdkDynMapperXsd> list = query.getResultList();
		return list;		
	}
	
	
	
	

}
